package de.infotheo;

import java.math.BigInteger;

public class ModInverse {

	public int modInverse(int x, int p) {
		int q = 0;
		BigInteger xbig = new BigInteger(String.valueOf(x));
		BigInteger pbig = new BigInteger(String.valueOf(p));
		String z = xbig.modInverse(pbig).toString();
		q = Integer.parseInt(z);
		System.out.println("Das Inverse von " + x + " ist: " + q);
		return q;
	}

}
